<div [@routerTransition]>
  <div class="m-subheader">
    <div class="d-flex align-items-center">
      <div class="mr-auto col-xs-6">
        <h3 class="m-subheader__title m-subheader__title--separator">
          <span>更改单</span>
        </h3>
        <span class="m-section__sub"> 更改单管理 </span>
      </div>
      <div class="col-xs-8 text-right mt-3 mt-md-0">
        <div class="btn-group dropdown mr-2" dropdown>
          <button dropdownToggle class="dropdown-toggle btn btn-outline-success">
            <i class="far fa-file-excel"></i><span class="caret"></span> Excel操作
          </button>
          <ul class="dropdown-menu dropdown-menu-right dropdown-excel-operations" *dropdownMenu>
            <li>
              <a href="javascript:;" (click)="exportToExcel()">
                <i class="fa fa-download"></i>
                {{'ExportToExcel' | localize}}
              </a>
            </li>
          </ul>
        </div>
        <button (click)="AlterItem.show()" class="btn btn-primary">
          <i class="fa fa-plus"> </i> 新建更改单
        </button>
      </div>
    </div>
  </div>
  <div class="m-content">
    <div class="m-portlet m-portlet--mobile">
      <div class="m-portlet__body">
        <form class="horizontal-form" autocomplete="off">
          <div class="m-form m-form--label-align-right">
            <div class="row align-items-center m--margin-bottom-10">
              <div class="col-xl-12">
                <div class="form-group m-form__group align-items-center">
                  <div class="input-group">
                    <input [(ngModel)]="filterText" name="filterText" autofocus class="form-control m-input"
                      [placeholder]="l('SearchWithThreeDot')" type="text" />
                    <span class="input-group-btn">
                      <button (click)="getModels()" class="btn btn-primary" type="submit">
                        <i class="flaticon-search-1" [attr.aria-label]="l('Search')"></i>
                      </button>
                    </span>
                  </div>
                </div>
              </div>
            </div>
            <div class="row m--margin-bottom-10" [hidden]="!advancedFiltersAreShown">
              <div class="col-md-4">
                <div class="form-group">
                  <date-range-empty-picker placeholder="选择日期范围" [(startDate)]="startFilterDate"
                    [(endDate)]="endFilterDate"></date-range-empty-picker>
                </div>
              </div>
            </div>

            <div class="row margin-bottom-10">
              <div class="col-sm-12">
                <span class="clickable-item text-muted" *ngIf="!advancedFiltersAreShown"
                  (click)="advancedFiltersAreShown=!advancedFiltersAreShown"><i class="fa fa-angle-down"></i>
                  {{"ShowAdvancedFilters" | localize}}</span>
                <span class="clickable-item text-muted" *ngIf="advancedFiltersAreShown"
                  (click)="advancedFiltersAreShown=!advancedFiltersAreShown"><i class="fa fa-angle-up"></i>
                  {{"HideAdvancedFilters" | localize}}</span>
              </div>
            </div>
          </div>
        </form>

        <div class="row align-items-center">
          <div class="primeng-datatable-container" [busyIf]="primengTableHelper.isLoading">
            <p-table #dataTable (onLazyLoad)="getModels($event)" [value]="primengTableHelper.records"
              rows="{{primengTableHelper.defaultRecordsCountPerPage}}" [paginator]="false" [lazy]="true"
              [scrollable]="true" ScrollWidth="100%" [responsive]="primengTableHelper.isResponsive"
              [resizableColumns]="primengTableHelper.resizableColumns">
              <ng-template pTemplate="header">
                <tr>
                  <th style="width:140px">操作</th>
                  <th pSortableColumn="AlterationInvoiceCode">
                    更改单号
                    <p-sortIcon field="AlterationInvoiceCode"></p-sortIcon>
                  </th>
                  <th pSortableColumn="CreatorUserId">
                    录入人
                    <p-sortIcon field="CreatorUserId"></p-sortIcon>
                  </th>
                  <th pSortableColumn="CreationTime">
                    录入时间
                    <p-sortIcon field="CreationTime"></p-sortIcon>
                  </th>
                </tr>
              </ng-template>
              <ng-template pTemplate="body" let-record="$implicit">
                <tr>
                  <td style="width: 140px">
                    <div class="btn-group dropdown" dropdown container="body">
                      <button dropdownToggle class="dropdown-toggle btn btn-sm btn-primary">
                        <i class="fa fa-cog"></i><span class="caret"></span> {{"Actions" | localize}}
                      </button>
                      <ul class="dropdown-menu" *dropdownMenu>
                        <li>
                          <a href="javascript:;" (click)="AlterItem.show(record.id)">{{'Edit' | localize}}</a>
                        </li>
                        <li>
                          <a href="javascript:;" (click)="deleteModel(record.id)">删除</a>
                        </li>
                      </ul>
                    </div>
                  </td>

                  <td>
                    <span class="ui-column-title">更改单号</span>
                    {{ record.alterationInvoiceCode}}
                  </td>
                  <td>
                    <span class="ui-column-title">录入人</span>
                    {{ record.createUserName}}
                  </td>
                  <td>
                    <span class="ui-column-title">接收时间</span>
                    {{ record.createTime | momentFormat:'YYYY-MM-DD HH:mm:ss'}}
                  </td>
                </tr>
              </ng-template>
            </p-table>
            <div class="primeng-no-data" *ngIf="primengTableHelper.totalRecordsCount == 0">
              {{'NoData' | localize}}
            </div>
            <div class="primeng-paging-container">
              <p-paginator [rows]="primengTableHelper.defaultRecordsCountPerPage" #paginator
                (onPageChange)="getModels($event)" [totalRecords]="primengTableHelper.totalRecordsCount"
                [rowsPerPageOptions]="primengTableHelper.predefinedRecordsCountPerPage">

              </p-paginator>
              <span class="total-records-count">
                {{'TotalRecordsCount' | localize:primengTableHelper.totalRecordsCount}}
              </span>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <AlterItem #AlterItem (modalSave)="reloadPage()"></AlterItem>
</div>
